Maps for WinRT
Offline Maps

Taking your maps offline is easy with Maps for WinRT. You can find a complete Offline Maps application installed with the ComponentOne Studio Samples folder. It should be installed in the following location:

C:\Users\YourUserName\Documents\ComponentOne Samples\WinRT XAML Phone\C1.Xaml.Maps\CS\OfflineMaps

In the sample, you'll notice a custom OfflineMapsSource class implementation:

C#
Copy Code
public class OfflineMapsSource : C1MultiScaleTileSource
{
    private const string uriFormat = @"ms-appx:/Resources/OfflineMaps/{Z}/{X}/{Y}.png";
    public OfflineMapsSource()
        : base(0x8000000, 0x8000000, 0x100, 0x100, 0)
    { }
    protected override void GetTileLayers(int tileLevel, int tilePositionX, int tilePositionY, IList<object> source)
    {
        if (tileLevel > 8)
        {
            var zoom = tileLevel - 8;
            var uri = uriFormat;
            uri = uri.Replace("{X}", tilePositionX.ToString());
            uri = uri.Replace("{Y}", tilePositionY.ToString());
            uri = uri.Replace("{Z}", zoom.ToString());
            source.Add(new Uri(uri));
        }
    }
}

In the above implementation, the class loads tile images from a local Resource folder. Note that the class inherits from the C1MultiScaleTileSource.

To use the custom tiles in an offline map, you need to set the C1MapsSource property. In this sample, an OnMapsLoaded event has been created and the Source property is set within this event:

C#
Copy Code
 void OnMapsLoaded(object sender, RoutedEventArgs e)
 {    
     this.maps.Source = new OfflineMapsSource();
 }

Creating an offline C1Maps control is that easy.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback